// Cretaed by Prem Singh

README

Contents

1.Introduction
2.Code
3.HOW TO RUN THE SCRIPT
4.DATABASE SCHEMA
5.Bug Reports and Feedback

Introduction:
This readme document gives instructions for getting stock quotes from http://finance.yahoo.com/ 
and store the retrieved information after parsing into mysql database.
Description:       A class to grab the latest stocks from Yahoo Finance
Created on:        Sat, 01 Mar 2008 14:01:46 +0200
Last Change:       Wed, 02 Mar 2008 12:59:35 +0200

Installation
To run this code you need to install PHP. You can install the latest version of php from 
http://us.php.net/get/php-4.4.8.tar.bz2/from/a/mirror and choose the default site or various 
mirror sites whichever you think is closest to your area.
You would need a ssh client which is available at:
http://www.vandyke.com/download/vshell/download.html
or http://www.openssh.com/windows.html 
We however used ssh of Rutgers University availabe at https://software.rutgers.edu/
which is only available to people affiliated to Rutgers University.




2. Code
     
The following codes are included in the zipped folder:

(i)  readme.txt
(ii) stocks.php

(i)  readme.txt: It gives step by step instructions for running the code to get the stockvalues. 
(ii) getstock.php: It is the php code to get the stock values from yahoofinance website.

3. HOW TO RUN THE SCRIPT
      
  
1. Start ssh Client and at the command prompt, enter the following:
   Hostname: software-ece.rutgers.edu
   Username:your_username
   Port No :22
   Password:your_password

2. Type 
shell> mysql -u user -p
Enter password: ********
& after you hit entre it would show:

SSH Secure Shell 3.2.9 (Build 283)
Copyright (c) 2000-2003 SSH Communications Security Corp - http://www.ssh.com/

This copy of SSH Secure Shell is a non-commercial version.
This version does not include PKI and PKCS #11 functionality.


Last login: Sun Mar  2 12:23:07 2008 from login.ruw.rutge
Sun Microsystems Inc.   SunOS 5.8       Generic February 2000
Sun Microsystems Inc.   SunOS 5.8       Generic February 2000
[group803](software-ece) ~/>mysql



3.then 'USE "database_name";' command to go to your database.

4.Use the following commands in mysql to create a table "STOCKS"

CREATE TABLE `STOCKS` (
      `ID` int(11) NOT NULL auto_increment,
      `stock` varchar(64) NOT NULL default '',
      `value` varchar(16) NOT NULL default '0',
      `changepoints` varchar(16) NOT NULL default '0',
      `open` varchar(16) NOT NULL default '',
      `intra_top` varchar(16) NOT NULL default '',
      `intra_down` varchar(16) NOT NULL default '',
      `date` varchar(10) NOT NULL default '',
      `time` varchar(6) NOT NULL default '',
      PRIMARY KEY  (`ID`)
      ) TYPE=MyISAM AUTO_INCREMENT=39 ;

5. To check if the table is created successfully type 
mysql> SHOW TABLES;
and it should show:
Empty set (0.00 sec) 

  

6. After the table has been created,type 
mysql> SHOW TABLES;
 

7.then  run the php script as follows

mysql> php getstock.php;

After the script is run, the database gets updated.


8. To view the database again goto mysql as described above and type

mysql> SELECT* FROM STOCKS;

That will display the full database. If you want so view Individual columns type
SELECT col_name FROM STOCKS;

9. For automatically getting the stock quote set it to run the php script in background 
every some time interval as needed.




4.DATABASE SCHEMA

mysql> describe STOCKS;
+--------------+-------------+------+-----+---------+----------------+
| Field        | Type        | Null | Key | Default | Extra          |
+--------------+-------------+------+-----+---------+----------------+
| ID           | int(11)     | YES  | PRI | NULL    | auto_increment |
| stock        | varchar(64) | YES  |     | 0       |                |
| value        | varchar(16) | YES  |     | 0       |                |
| changepoints | varchar(16) | YES  |     | 0       |                |
| open         | varchar(16) | YES  |     | 0       |                |
| intra_top    | varchar(16) | YES  |     | 0       |                |
| intra_down   | varchar(16) | YES  |     | 0       |                |
| date         | varchar(10) | YES  |     | 0       |                |
| time         | varchar(6)  | YES  |     | 0       |                |
+--------------+-------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)

 
5.Bug Reports and Feedback
Please feel free to write if you find any bug or if you have any questions or feedback about this work at
premsing@eden.rutgers.edu



